<!DOCTYPE html>
<html>
<head>
    <title>我来回答</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
    <link rel="stylesheet" href="/css/reset.css" />
    <link rel="stylesheet" href="/css/myInfo.css" />
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css" />
    <link rel="stylesheet" href="/css/font/community.css" />
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/form/jquery.form.js"></script>
    <script src="/js/checkLogin.js"></script>
    <script src="/js/common.js"></script>
</head>

<body style="background: url('/upload/2.bmp')">
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:window.history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col" align="center">
            <span>问答大厅</span>
        </div>
        <div class="col"></div>
    </div>
</div>
<div class="container tags">
</div>

<div class="container communities">
    <div class="row classify " render-loop="list">
        <div class="col-12 mb">
            <a role="button" render-key="list.id" render-fun="handle">
                <img class="float-left rounded-circle" width="20%" render-src="list.author.headImgUrl">
                <div class="classify-text">
                    <p class="authorName">
                        <span render-html="list.author.nickName"></span>
                        <span class="comment-date" render-html="list.releaseTime"></span>
                    </p>
                    <span render-html="list.title"></span>
                    <br>&nbsp;
                </div>
            </a>
        </div>
    </div>
</div>
<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
    <!-- 选项卡 -->
    <li class="nav-item">

        <button class="nav-link active show btn-block" id="pills-top-tab" data-toggle="pill" onclick="turnOver()">
            <span style="font-weight: bold;">我要提问</span>
        </button>
    </li>
</ul>
<script>
    function turnOver(){
          window.location.href="/mine/editTravelTroubles.html";
    }


    $(function () {

        var currentPage = 1;
        var travels;
        var pages;

        // 从本地session中取出缓存的对象,渲染到页面
        var user = JSON.parse(sessionStorage.getItem("user"));
        // 发请求获取数据
        $.get(baseUrl+"/users/travelTroubles", {pageSize: 3,state:1}, function (data) {
            console.log(data);
            renderView(data);
            //console.log(data);
            travels = data.list;
            // 需要用到总页数,所以先获取
            pages = data.pages;
            console.log(pages);
        });

        $(window).scroll(function () {
            console.log(isEnd());
            if (isEnd()) {
                if (currentPage < pages) {
                    currentPage++;
                    console.log(currentPage);
                    $.get(baseUrl+"/users/travelTroubles", {
                        currentPage: currentPage,
                        pageSize: 3,
                        state:1
                    }, function (data) {
                        $.merge(travels, data.list);
                        renderView({list: travels});
                    });
                } else {
                    $(document).dialog({
                        type: 'notice',
                        infoText: '我也是有底线的',
                        autoClose: 1500,
                        position: 'bottom'  // center: 居中; bottom: 底部
                    });
                }
            }
        })

    });

    function renderView(data) {
        $(".communities").renderValues(data, {
            handle: function (ele, value) {
                $(ele).attr("href", "/mine/troubleContent.html?id=" + value);
            }
        });
    }
</script>
</body>
</html>
